﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using SharedGenomics.Core;
using SharedGenomics.Workbench.Core;

namespace SharedGenomics.Workbench.Views.WindowsForms
{
    public partial class MainFormView : View, IMainFormView
    {
        public MainFormView()
        {
            InitializeComponent();
        }

        public IView MainView
        {
            set
            {
                this.SetPanelContent(this.scForm.Panel2, (Control)value);
            }
        }

        public IMenu Menu
        {
            set
            {
                this.SetPanelContent(this.scForm.Panel1, (Control)value);
            }
        }

        private void SetPanelContent(Panel parent, Control content)
        {
            content.Dock = DockStyle.Fill;
            parent.Controls.Clear();

            if (content != null)
            {
                parent.Controls.Add(content);
            }
        }

        public void AddMenuBarMenu(IMenuBarMenu menu)
        {
            ToolStripMenuItem menuItem = menu as ToolStripMenuItem;
            menuItem.ThrowIfNull<ArgumentException>("Invalid menu type - expected System.Windows.Forms.ToolStripMenuItem");

            this.menuStrip1.Items.Add(menuItem);
        }
    }
}
